﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace AWA.VAT.EmailApp.Progress
{
    public partial class ProgressForm : Form
    {
        public bool EnableCancel
        {
            get { return btnCancel.Visible; }
            set
            {
                btnCancel.Visible = value;
                Size size = new Size();
                size.Height = progressBar1.Size.Height;
                size.Width = pnlProgress.Size.Width - (value ? 106 : 25); // 384/278/359
                progressBar1.Size = size;
                progressBar1.Refresh();
            }
        }

        public bool Cancelled { get; private set; }

        public int Maximum
        {
            get { return progressBar1.Maximum; }
            set { progressBar1.Maximum = value; }
        }

        public int Increment
        {
            get { return progressBar1.Step; }
            set { progressBar1.Step = value; }
        }

        public string ProgressText
        {
            get { return lblMessage.Text; }
            set { lblMessage.Text = value; }
        }

        public ProgressForm()
        {
            InitializeComponent();
        }

        public void Step()
        {
            progressBar1.Increment(Increment);
        }

        public void Reset()
        {
            this.Reset(progressBar1.Maximum);
        }

        public void Reset(int newMax)
        {
            progressBar1.Value = 0;
            progressBar1.Text = "starting...";
            progressBar1.Maximum = newMax;
        }

        private void HandleCancelButtonClick(object sender, EventArgs e)
        {
            Cancelled = true;
        }
    }
}
